package com.example.xiaoyi.weiju;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.xiaoyi.weiju.Overing.ActivityHome;
import com.example.xiaoyi.weiju.Overing.GudieActivity;

public class WelcomeActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);
        new Handler(new Handler.Callback() {
            @Override
            public boolean handleMessage(Message msg) {
                if(isFirstRun()){
                    startActivity(new Intent(WelcomeActivity.this,GudieActivity.class));
                }else {
                    startActivity(new Intent(WelcomeActivity.this,ActivityHome.class));
                }
                return false;
            }
        }).sendEmptyMessageDelayed(0,2500);
    }
    private boolean isFirstRun(){
        SharedPreferences preferences = getSharedPreferences("app",MODE_PRIVATE);
        boolean isFirst = preferences.getBoolean("first_run",true);
        if(isFirst){
            preferences.edit().putBoolean("first_run",false).commit();
        }
        return  false;
    }
}
